package com.example.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.common.dto.Acticledto;
import com.example.common.dto.ArticleInfo;
import com.example.common.pojo.musicarticle;
import com.example.common.pojo.musictag;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface MusicArticleMapper extends BaseMapper<musicarticle> {

//文章展示数据加查询
    @Select("SELECT a.*,u.`name`,u.userimg FROM musicarticle a,musicuser u WHERE a.author_id=u.id AND a.title LIKE '%${name}%'")
    Page<Acticledto> selectArticlePage(Page<Acticledto> page, @Param("name") String name);

    @Select("SELECT a.*,u.`name`,u.userimg FROM musicarticle a,musicuser u,musicarticletag t WHERE a.author_id=u.id AND t.article_id=a.id AND t.tag_id= #{tagid} ")
    Page<Acticledto> selectArticleTagPage(Page<Acticledto> page,@Param("tagid") Long tagid);

    @Select("SELECT tinfo.* FROM musicarticletag t,musictag tinfo WHERE t.tag_id=tinfo.id and t.article_id= #{id}")
    List<musictag> listtag(@Param("id") Long id);

    @Select("SELECT a.*,u.`name`,u.userimg,b.content_html,b.content FROM musicarticle a, musicarticlebody b,musicuser u WHERE a.id=b.article_id AND a.author_id=u.id AND a.id=${id}")
    ArticleInfo selectArticleInfo(@Param("id") Long id);


    int updatecategoryIdById(Long id, Long categoryId);

    int startandstop(Long id);

    int allremoveById(Long id);
}
